package com.aaa.marketing.service.impl;/**
 * Date:2023/3/2
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.Advertise;
import com.aaa.marketing.dao.AdvertiseDao;
import com.aaa.marketing.service.AdvertiseService;
import com.aaa.vo.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/2 10:51
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class AdvertiseServiceImpl implements AdvertiseService {
    @Autowired
    private AdvertiseDao advertiseDao;
    @Override
    public Result selectAll(int currentPage, int pageSize, Advertise advertise) {
        PageHelper.startPage(currentPage,pageSize);
        List<Advertise> advertises = advertiseDao.selectAll(advertise);
        PageInfo<Advertise> advertisePageInfo = new PageInfo<>(advertises);
        return new Result(2000,"成功",advertisePageInfo);
    }

    @Override
    public Result update(Advertise advertise) {
        int i = advertiseDao.updateById(advertise);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result delete(Integer id) {
        int i = advertiseDao.deleteById(id);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result insert(Advertise advertise) {
        int insert = advertiseDao.insert(advertise);
        return new Result(2000,"成功",insert);
    }

    @Override
    public Result updateStatus(Integer id, Integer status) {
        return new Result(2000,"成功",advertiseDao.updateStatus(id,status));
    }

    @Override
    public Result selectCount(Integer positionId) {
        Integer integer = advertiseDao.selectCount1(positionId);
        return new Result(2000,"成功",integer);
    }

    @Override
    public Result selectMaxCount(Integer positionId) {
        Integer integer = advertiseDao.selectMaxCount(positionId);
        return new Result(2000,"成功",integer);
    }


}